#!/bin/bash
ip=192.168.56.101
user=root
password=root
expect <<EOF
    set timeout 10
    spawn ssh $user@$ip
    expect {
        "yes/no" { send "yes\n"; exp_continue }
        "password" { send "$password\n"}
    }
    expect "]#" { send "ip a\n" }
    expect "]#" { send "exit\n" } expect eof 
EOF

# expect "]#" { send "useradd hehe\n" } 
# expect "]#" { send "echo rrr|passwd --stdin hehe\n" } 
# expect "]#" { send "exit\n" } expect eof 
# expect "]#" {send "ip a\n"} expect eof
